﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using TCPClient.RequestsToServerHandlers;

namespace TCPClient.UI
{
    public partial class ManagerMainForm : Form
    {
        private RequestsToServerHandlerForManager m_ManagerRequestHandler = null;

        public ManagerMainForm(RequestsToServerHandler handler)
        {
            InitializeComponent();
            scMainManagerUserControl1.ManagerRequestHandler = handler as RequestsToServerHandlerForManager;
            m_ManagerRequestHandler = handler as RequestsToServerHandlerForManager;
            this.Text += (@" - " + m_ManagerRequestHandler.LoggedInManager.PersonalDetails.FullName);
        }


        private void refreshToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.scMainManagerUserControl1.RefreshAll();
        }


        private void toolStripButtonREFRESH_Click(object sender, EventArgs e)
        {
            this.scMainManagerUserControl1.RefreshAll();
        }

        private void toolStripButtonExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void toolStripButtonRunShiftOrganaizor_Click(object sender, EventArgs e)
        {
            AlgoExecuterForm algoExecuterForm = new AlgoExecuterForm();
            algoExecuterForm.AlgoFinished += enableSendMailButton;
            algoExecuterForm.ShowDialog();
            
        }

        private void enableSendMailButton(object sender, EventArgs e)
        {
            toolStripButtonSendMail.Enabled = true;
        }

        private void toolStripButtonSettings_Click(object sender, EventArgs e)
        {
            SettingsForm sf = new SettingsForm();
            sf.ShowDialog();
        }

        private void toolStripButtonSendMail_Click(object sender, EventArgs e)
        {
            scMainManagerUserControl1.PublishWorkOrder();
        }

        private void toolStripMenuItemGeneralSatisfactionRank_Click(object sender, EventArgs e)
        {
            WorkerRankingForm wrf = new WorkerRankingForm(eStatType.Aggregative);
            wrf.ShowDialog();
        }

        private void toolStripMenuItemWeeklysatisfactionRank_Click(object sender, EventArgs e)
        {
            WorkerRankingForm wrf = new WorkerRankingForm(eStatType.Weekly);
            wrf.ShowDialog();
        }

    }
}
